package online.yangcloud.core.model.entity;

import com.mybatisflex.annotation.Column;
import com.mybatisflex.annotation.Id;
import com.mybatisflex.annotation.Table;
import online.yangcloud.common.annotation.DataColumn;
import online.yangcloud.common.annotation.DataIndex;
import online.yangcloud.common.annotation.DataTable;
import online.yangcloud.common.enumration.ColumnTypeEnum;
import online.yangcloud.common.model.BaseParameter;
import org.springframework.stereotype.Component;

/**
 * 文件块元数据
 *
 * @author zhuboyang
 * @since 2023年01月01 21:52:34
 */
@Table(value = "block_metadata")
@DataTable(tableName = "block_metadata", desc = "文件块元数据")
@Component
public class BlockEntity extends BaseParameter {

    /**
     * id
     */
    @DataColumn(primary = true, name = "id", type = ColumnTypeEnum.VARCHAR, length = 32, canNull = false, comment = "文件块 id")
    @DataIndex(unique = true)
    @Id(value = "id")
    private String id;

    /**
     * 文件块 md5
     */
    @DataColumn(name = "hash", type = ColumnTypeEnum.VARCHAR, length = 32, canNull = false, comment = "文件块 hash")
    @DataIndex(unique = true)
    @Column(value = "hash")
    private String hash;

    /**
     * 文件块存储路径
     */
    @DataColumn(name = "path", type = ColumnTypeEnum.VARCHAR, length = 1000, canNull = false, comment = "文件块存储路径")
    @Column(value = "path")
    private String path;

    /**
     * 文件块大小
     */
    @DataColumn(name = "size", type = ColumnTypeEnum.BIGINT, canNull = false, comment = "文件块大小")
    @Column(value = "size")
    private Long size;

    public static BlockEntity builder() {
        return new BlockEntity();
    }

    public String getId() {
        return id;
    }

    public BlockEntity setId(String id) {
        this.id = id;
        return this;
    }

    public String getHash() {
        return hash;
    }

    public BlockEntity setHash(String hash) {
        this.hash = hash;
        return this;
    }

    public String getPath() {
        return path;
    }

    public BlockEntity setPath(String path) {
        this.path = path;
        return this;
    }

    public Long getSize() {
        return size;
    }

    public BlockEntity setSize(Long size) {
        this.size = size;
        return this;
    }

    @Override
    public String toString() {
        return "BlockMetadata["
                + " id=" + id + ","
                + " hash=" + hash + ","
                + " path=" + path + ","
                + " size=" + size + ","
                + " ]"
                + " "
                + super.toString();
    }
}
